import 'dart:ffi';

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:lepig/common/config/theme.dart';
import 'package:lepig/model/ProductModel.dart';

// 横排正方形两个商品
// ignore: must_be_immutable
class GoodsHorizontalTwo extends StatelessWidget {
  GoodsHorizontalTwo(this.productModel);
  ProductModel productModel;
  BuildContext context;

  @override
  Widget build(BuildContext context) {
    this.context = context;
    // TODO: implement build
    return  _product();
  }

  Widget _product() {
    return new Container(
        decoration: new BoxDecoration(
          color: Colors.white,
          borderRadius: BorderRadius.circular(10.0),
        ),
        child: new GestureDetector(
            onTap: () {
//              Navigator.of(context).pushNamed("/product");
              Navigator.of(context).pushNamed("/product",arguments: productModel);
            },
            child: new Column(
              children: <Widget>[
                new ClipRRect(
                  borderRadius: BorderRadius.circular(10.0),
                  child: new Image.network(
                    productModel.pic,height: 200.0,
                    fit: BoxFit.cover,
                  ),
                ),
                new Padding(
                  padding: EdgeInsets.all(10.0),
                  child: Column(
                    children: <Widget>[
                      new Text(
                        productModel.title,
                        maxLines: 2,
                        overflow: TextOverflow.ellipsis,
                        style: TextStyle(fontSize: 15.0),
                      ),
                    ],
                  ),
                ),
                new Padding(
                  padding: EdgeInsets.only(left: 10, right: 10),
                  child: new Row(
                    mainAxisAlignment: MainAxisAlignment.spaceBetween,
                    children: <Widget>[
                      double.parse(productModel.couponPrice)>0?new Container(
                        child: new Text(
                          productModel.couponPrice +"元券",
                          style: TextStyle(color: Colors.white, fontSize: 12.0),
                        ),
                        padding: EdgeInsets.only(left: 10.0, right: 10.0),
                        decoration: BoxDecoration(
                          color: Color.fromRGBO(255, 140, 41, 1),
                          borderRadius: BorderRadius.circular(5.0),
                        ),
                        alignment: Alignment.center,
                        height: 20.0,
                      ):SizedBox(),
                      new Text(productModel.sale+"购买",style: TextStyle(
                        color: curFontBgColor,
                        fontSize: 12.0
                      ),)
                    ],
                  ),
                ),
                new SizedBox(
                  height: 10.0,
                ),
                new Padding(
                  padding: EdgeInsets.only(left: 10, right: 10),
                  child: new Row(
                    mainAxisAlignment: MainAxisAlignment.spaceBetween,
                    children: <Widget>[
                      new Row(
                        children: <Widget>[
                          new Text(
                            "券后",
                            style: TextStyle(color: Colors.red, fontSize: 11.0),
                          ),
                          new Text(
                            "￥",
                            style: TextStyle(color: Colors.red, fontSize: 12.0),
                          ),
                          new Text(
                            productModel.finalPrice,
                            style: TextStyle(
                                color: Colors.red,
                                fontSize: 15.0,
                                fontWeight: FontWeight.bold),
                          ),
                        ],
                      ),
                      new Text(
                        " 原价￥"+ productModel.originalPrice,
                        style: TextStyle(
                            color: Color.fromRGBO(189, 188, 188, 1),
                            decoration: TextDecoration.lineThrough,
                            fontSize: 10.0),
                      ),
                    ],
                  ),
                ),
                new SizedBox(
                  height: 10.0,
                ),
              ],
            )),
      );
  }
}
